package cn.tedu.mall.seckill.controller;

import cn.tedu.mall.common.restful.JsonResult;
import cn.tedu.mall.pojo.seckill.vo.SeckillSkuVO;
import cn.tedu.mall.seckill.service.ISeckillSkuService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author BJ
 * @date 2022/11/10 20:50
 */
@RestController
@RequestMapping("/seckill/sku")
@Api(tags = "秒杀sku商品模块")
@Slf4j
public class SeckillSkuController {
    @Autowired
    private ISeckillSkuService skuService;

    @GetMapping("/{spuId}")
    @ApiOperation("根据spuId查询要秒杀的sku商品信息")
    @ApiImplicitParam(value = "spuId",name = "spuId",example = "2")
    public JsonResult<List<SeckillSkuVO>> getSeckillSku(@PathVariable Long spuId){
        List<SeckillSkuVO> seckillSkuVOS = skuService.listSeckillSkus(spuId);
        return JsonResult.ok(seckillSkuVOS);
    }

}
